import java.util.Arrays;

/**
 * @author LKQ
 * @date 2021/12/22 17:43
 * @description 依照题目意思，直接排序后再比较同位置的是否相同。
 */
public class Solution {
    public static void main(String[] args) {

    }

    public int heightChecker(int[] heights) {
        int n = heights.length;
        int[] expected = Arrays.copyOf(heights, n);
        Arrays.sort(expected);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (expected[i] != heights[i]) {
                ans++;
            }
        }
        return ans;
    }
}
